<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Locale::Maketext::TPJ13 -- article about software localization - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Locale::Maketext::TPJ13">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Locale::Maketext::TPJ13.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Locale::Maketext::TPJ13">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Locale::Maketext::TPJ13">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Locale::Maketext::TPJ13">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Locale::Maketext::TPJ13">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Locale::Maketext::TPJ13">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Locale::Maketext::TPJ13">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Locale::Maketext::TPJ13">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Locale::Maketext::TPJ13">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Locale::Maketext::TPJ13">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Locale::Maketext::TPJ13">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Locale::Maketext::TPJ13">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Locale::Maketext::TPJ13">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Locale::Maketext::TPJ13">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Locale::Maketext::TPJ13">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Locale::Maketext::TPJ13">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Locale::Maketext::TPJ13">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Locale::Maketext::TPJ13">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Locale::Maketext::TPJ13">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Locale::Maketext::TPJ13">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Locale::Maketext::TPJ13">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Locale::Maketext::TPJ13">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Locale::Maketext::TPJ13">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Locale::Maketext::TPJ13">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Locale::Maketext::TPJ13">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Locale::Maketext::TPJ13">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Locale::Maketext::TPJ13">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Locale::Maketext::TPJ13">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Locale::Maketext::TPJ13">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Locale::Maketext::TPJ13">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Locale::Maketext::TPJ13">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Locale::Maketext::TPJ13">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Locale::Maketext::TPJ13">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Locale::Maketext::TPJ13">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Locale::Maketext::TPJ13">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Locale::Maketext::TPJ13">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Locale::Maketext::TPJ13">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Locale::Maketext::TPJ13">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Locale::Maketext::TPJ13">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Locale::Maketext::TPJ13">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Locale::Maketext::TPJ13">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Locale::Maketext::TPJ13">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Locale::Maketext::TPJ13">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Locale::Maketext::TPJ13">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Locale::Maketext::TPJ13">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Locale::Maketext::TPJ13">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Locale::Maketext::TPJ13">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Locale::Maketext::TPJ13">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Locale::Maketext::TPJ13">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Locale::Maketext::TPJ13">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Locale::Maketext::TPJ13">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Locale::Maketext::TPJ13">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Locale::Maketext::TPJ13">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Locale::Maketext::TPJ13">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Locale::Maketext::TPJ13">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Locale::Maketext::TPJ13">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Locale::Maketext::TPJ13">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Locale::Maketext::TPJ13">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Locale::Maketext::TPJ13">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Locale::Maketext::TPJ13">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Locale::Maketext::TPJ13">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Locale::Maketext::TPJ13">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Locale::Maketext::TPJ13">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Locale::Maketext::TPJ13">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Locale::Maketext::TPJ13">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Locale::Maketext::TPJ13">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Locale::Maketext::TPJ13">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Locale::Maketext::TPJ13">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Locale::Maketext::TPJ13">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Locale::Maketext::TPJ13">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Locale::Maketext::TPJ13">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Locale::Maketext::TPJ13">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Locale::Maketext::TPJ13">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Locale::Maketext::TPJ13">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Locale::Maketext::TPJ13">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Locale::Maketext::TPJ13">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Locale::Maketext::TPJ13">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Locale::Maketext::TPJ13">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Locale::Maketext::TPJ13">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Locale::Maketext::TPJ13">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Locale::Maketext::TPJ13">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Locale::Maketext::TPJ13.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Locale::Maketext::TPJ13">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Locale::Maketext::TPJ13">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Locale::Maketext::TPJ13">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Locale::Maketext::TPJ13">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Locale::Maketext::TPJ13">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Locale::Maketext::TPJ13">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Locale::Maketext::TPJ13">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Locale::Maketext::TPJ13">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Locale::Maketext::TPJ13">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Locale::Maketext::TPJ13">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Locale::Maketext::TPJ13">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Locale::Maketext::TPJ13">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Locale::Maketext::TPJ13">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Locale::Maketext::TPJ13">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Locale::Maketext::TPJ13">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Locale::Maketext::TPJ13">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Locale::Maketext::TPJ13">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Locale::Maketext::TPJ13">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Locale::Maketext::TPJ13">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Locale::Maketext::TPJ13">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Locale::Maketext::TPJ13">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Locale::Maketext::TPJ13">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Locale::Maketext::TPJ13">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Locale::Maketext::TPJ13">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Locale::Maketext::TPJ13">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Locale::Maketext::TPJ13">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Locale::Maketext::TPJ13">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Locale::Maketext::TPJ13">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Locale::Maketext::TPJ13">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Locale::Maketext::TPJ13">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Locale::Maketext::TPJ13">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Locale::Maketext::TPJ13">5.35.1</a>
          <a class="dropdown-item active" href="./Locale::Maketext::TPJ13.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Locale::Maketext::TPJ13.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Locale::Maketext::TPJ13.html">Locale::Maketext::TPJ13</a>
          <div id="more">
            (<a href="./Locale::Maketext::TPJ13.txt">source</a>,
            <a href="https://metacpan.org/pod/Locale::Maketext::TPJ13">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Localization-and-Perl:-gettext-breaks,-Maketext-fixes">Localization and Perl: gettext breaks, Maketext fixes</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#A-Localization-Horror-Story:-It-Could-Happen-To-You">A Localization Horror Story: It Could Happen To You</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#The-Linguistic-View">The Linguistic View</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Breaking-gettext">Breaking gettext</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Replacing-gettext">Replacing gettext</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Buzzwords:-Abstraction-and-Encapsulation">Buzzwords: Abstraction and Encapsulation</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Buzzword:-Isomorphism">Buzzword: Isomorphism</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Buzzword:-Inheritance">Buzzword: Inheritance</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#Buzzword:-Concision">Buzzword: Concision</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#The-Devil-in-the-Details">The Devil in the Details</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#The-Proof-in-the-Pudding:-Localizing-Web-Sites">The Proof in the Pudding: Localizing Web Sites</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Locale::Maketext::TPJ13.html#References">References</a>
              </li>
          </ul>

              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Locale::Maketext::TPJ13.html#NAME">#</a>NAME</h1>

<p>Locale::Maketext::TPJ13 -- article about software localization</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Locale::Maketext::TPJ13.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code class="plaintext"># This an article, not a module.</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="./Locale::Maketext::TPJ13.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>The following article by Sean M. Burke and Jordan Lachler first appeared in <i>The Perl Journal</i> #13 and is copyright 1999 The Perl Journal. It appears courtesy of Jon Orwant and The Perl Journal. This document may be distributed under the same terms as Perl itself.</p>

<h1 id="Localization-and-Perl:-gettext-breaks,-Maketext-fixes"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Localization-and-Perl:-gettext-breaks,-Maketext-fixes">#</a><a id="Localization"></a><a id="Localization-and-Perl:-gettext-breaks-Maketext-fixes"></a>Localization and Perl: gettext breaks, Maketext fixes</h1>

<p>by Sean M. Burke and Jordan Lachler</p>

<p>This article points out cases where gettext (a common system for localizing software interfaces -- i.e., making them work in the user&#39;s language of choice) fails because of basic differences between human languages. This article then describes Maketext, a new system capable of correctly treating these differences.</p>

<h2 id="A-Localization-Horror-Story:-It-Could-Happen-To-You"><a class="permalink" href="./Locale::Maketext::TPJ13.html#A-Localization-Horror-Story:-It-Could-Happen-To-You">#</a><a id="A"></a>A Localization Horror Story: It Could Happen To You</h2>

<ul>

<p>&quot;There are a number of languages spoken by human beings in this world.&quot;</p>

<p>-- Harald Tveit Alvestrand, in RFC 1766, &quot;Tags for the Identification of Languages&quot;</p>

</ul>

<p>Imagine that your task for the day is to localize a piece of software -- and luckily for you, the only output the program emits is two messages, like this:</p>

<pre><code class="plaintext">I scanned 12 directories.

Your query matched 10 files in 4 directories.</code></pre>

<p>So how hard could that be? You look at the code that produces the first item, and it reads:</p>

<pre><code>printf(&quot;I scanned %g directories.&quot;,
       $directory_count);</code></pre>

<p>You think about that, and realize that it doesn&#39;t even work right for English, as it can produce this output:</p>

<pre><code class="plaintext">I scanned 1 directories.</code></pre>

<p>So you rewrite it to read:</p>

<pre><code>printf(&quot;I scanned %g %s.&quot;,
       $directory_count,
       $directory_count == 1 ?
         &quot;directory&quot; : &quot;directories&quot;,
);</code></pre>

<p>...which does the Right Thing. (In case you don&#39;t recall, &quot;%g&quot; is for locale-specific number interpolation, and &quot;%s&quot; is for string interpolation.)</p>

<p>But you still have to localize it for all the languages you&#39;re producing this software for, so you pull Locale::gettext off of CPAN so you can access the <code>gettext</code> C functions you&#39;ve heard are standard for localization tasks.</p>

<p>And you write:</p>

<pre><code>printf(gettext(&quot;I scanned %g %s.&quot;),
       $dir_scan_count,
       $dir_scan_count == 1 ?
         gettext(&quot;directory&quot;) : gettext(&quot;directories&quot;),
);</code></pre>

<p>But you then read in the gettext manual (Drepper, Miller, and Pinard 1995) that this is not a good idea, since how a single word like &quot;directory&quot; or &quot;directories&quot; is translated may depend on context -- and this is true, since in a case language like German or Russian, you&#39;d may need these words with a different case ending in the first instance (where the word is the object of a verb) than in the second instance, which you haven&#39;t even gotten to yet (where the word is the object of a preposition, &quot;in %g directories&quot;) -- assuming these keep the same syntax when translated into those languages.</p>

<p>So, on the advice of the gettext manual, you rewrite:</p>

<pre><code>printf( $dir_scan_count == 1 ?
         gettext(&quot;I scanned %g directory.&quot;) :
         gettext(&quot;I scanned %g directories.&quot;),
       $dir_scan_count );</code></pre>

<p>So, you email your various translators (the boss decides that the languages du jour are Chinese, Arabic, Russian, and Italian, so you have one translator for each), asking for translations for &quot;I scanned %g directory.&quot; and &quot;I scanned %g directories.&quot;. When they reply, you&#39;ll put that in the lexicons for gettext to use when it localizes your software, so that when the user is running under the &quot;zh&quot; (Chinese) locale, gettext(&quot;I scanned %g directory.&quot;) will return the appropriate Chinese text, with a &quot;%g&quot; in there where printf can then interpolate $dir_scan.</p>

<p>Your Chinese translator emails right back -- he says both of these phrases translate to the same thing in Chinese, because, in linguistic jargon, Chinese &quot;doesn&#39;t have number as a grammatical category&quot; -- whereas English does. That is, English has grammatical rules that refer to &quot;number&quot;, i.e., whether something is grammatically singular or plural; and one of these rules is the one that forces nouns to take a plural suffix (generally &quot;s&quot;) when in a plural context, as they are when they follow a number other than &quot;one&quot; (including, oddly enough, &quot;zero&quot;). Chinese has no such rules, and so has just the one phrase where English has two. But, no problem, you can have this one Chinese phrase appear as the translation for the two English phrases in the &quot;zh&quot; gettext lexicon for your program.</p>

<p>Emboldened by this, you dive into the second phrase that your software needs to output: &quot;Your query matched 10 files in 4 directories.&quot;. You notice that if you want to treat phrases as indivisible, as the gettext manual wisely advises, you need four cases now, instead of two, to cover the permutations of singular and plural on the two items, $dir_count and $file_count. So you try this:</p>

<pre><code>printf( $file_count == 1 ?
  ( $directory_count == 1 ?
   gettext(&quot;Your query matched %g file in %g directory.&quot;) :
   gettext(&quot;Your query matched %g file in %g directories.&quot;) ) :
  ( $directory_count == 1 ?
   gettext(&quot;Your query matched %g files in %g directory.&quot;) :
   gettext(&quot;Your query matched %g files in %g directories.&quot;) ),
 $file_count, $directory_count,
);</code></pre>

<p>(The case of &quot;1 file in 2 [or more] directories&quot; could, I suppose, occur in the case of symlinking or something of the sort.)</p>

<p>It occurs to you that this is not the prettiest code you&#39;ve ever written, but this seems the way to go. You mail off to the translators asking for translations for these four cases. The Chinese guy replies with the one phrase that these all translate to in Chinese, and that phrase has two &quot;%g&quot;s in it, as it should -- but there&#39;s a problem. He translates it word-for-word back: &quot;In %g directories contains %g files match your query.&quot; The %g slots are in an order reverse to what they are in English. You wonder how you&#39;ll get gettext to handle that.</p>

<p>But you put it aside for the moment, and optimistically hope that the other translators won&#39;t have this problem, and that their languages will be better behaved -- i.e., that they will be just like English.</p>

<p>But the Arabic translator is the next to write back. First off, your code for &quot;I scanned %g directory.&quot; or &quot;I scanned %g directories.&quot; assumes there&#39;s only singular or plural. But, to use linguistic jargon again, Arabic has grammatical number, like English (but unlike Chinese), but it&#39;s a three-term category: singular, dual, and plural. In other words, the way you say &quot;directory&quot; depends on whether there&#39;s one directory, or <i>two</i> of them, or <i>more than two</i> of them. Your test of <code>($directory == 1)</code> no longer does the job. And it means that where English&#39;s grammatical category of number necessitates only the two permutations of the first sentence based on &quot;directory [singular]&quot; and &quot;directories [plural]&quot;, Arabic has three -- and, worse, in the second sentence (&quot;Your query matched %g file in %g directory.&quot;), where English has four, Arabic has nine. You sense an unwelcome, exponential trend taking shape.</p>

<p>Your Italian translator emails you back and says that &quot;I searched 0 directories&quot; (a possible English output of your program) is stilted, and if you think that&#39;s fine English, that&#39;s your problem, but that <i>just will not do</i> in the language of Dante. He insists that where $directory_count is 0, your program should produce the Italian text for &quot;I <i>didn&#39;t</i> scan <i>any</i> directories.&quot;. And ditto for &quot;I didn&#39;t match any files in any directories&quot;, although he says the last part about &quot;in any directories&quot; should probably just be left off.</p>

<p>You wonder how you&#39;ll get gettext to handle this; to accommodate the ways Arabic, Chinese, and Italian deal with numbers in just these few very simple phrases, you need to write code that will ask gettext for different queries depending on whether the numerical values in question are 1, 2, more than 2, or in some cases 0, and you still haven&#39;t figured out the problem with the different word order in Chinese.</p>

<p>Then your Russian translator calls on the phone, to <i>personally</i> tell you the bad news about how really unpleasant your life is about to become:</p>

<p>Russian, like German or Latin, is an inflectional language; that is, nouns and adjectives have to take endings that depend on their case (i.e., nominative, accusative, genitive, etc...) -- which is roughly a matter of what role they have in syntax of the sentence -- as well as on the grammatical gender (i.e., masculine, feminine, neuter) and number (i.e., singular or plural) of the noun, as well as on the declension class of the noun. But unlike with most other inflected languages, putting a number-phrase (like &quot;ten&quot; or &quot;forty-three&quot;, or their Arabic numeral equivalents) in front of noun in Russian can change the case and number that noun is, and therefore the endings you have to put on it.</p>

<p>He elaborates: In &quot;I scanned %g directories&quot;, you&#39;d <i>expect</i> &quot;directories&quot; to be in the accusative case (since it is the direct object in the sentence) and the plural number, except where $directory_count is 1, then you&#39;d expect the singular, of course. Just like Latin or German. <i>But!</i> Where $directory_count % 10 is 1 (&quot;%&quot; for modulo, remember), assuming $directory count is an integer, and except where $directory_count % 100 is 11, &quot;directories&quot; is forced to become grammatically singular, which means it gets the ending for the accusative singular... You begin to visualize the code it&#39;d take to test for the problem so far, <i>and still work for Chinese and Arabic and Italian</i>, and how many gettext items that&#39;d take, but he keeps going... But where $directory_count % 10 is 2, 3, or 4 (except where $directory_count % 100 is 12, 13, or 14), the word for &quot;directories&quot; is forced to be genitive singular -- which means another ending... The room begins to spin around you, slowly at first... But with <i>all other</i> integer values, since &quot;directory&quot; is an inanimate noun, when preceded by a number and in the nominative or accusative cases (as it is here, just your luck!), it does stay plural, but it is forced into the genitive case -- yet another ending... And you never hear him get to the part about how you&#39;re going to run into similar (but maybe subtly different) problems with other Slavic languages like Polish, because the floor comes up to meet you, and you fade into unconsciousness.</p>

<p>The above cautionary tale relates how an attempt at localization can lead from programmer consternation, to program obfuscation, to a need for sedation. But careful evaluation shows that your choice of tools merely needed further consideration.</p>

<h2 id="The-Linguistic-View"><a class="permalink" href="./Locale::Maketext::TPJ13.html#The-Linguistic-View">#</a><a id="The"></a>The Linguistic View</h2>

<ul>

<p>&quot;It is more complicated than you think.&quot;</p>

<p>-- The Eighth Networking Truth, from RFC 1925</p>

</ul>

<p>The field of Linguistics has expended a great deal of effort over the past century trying to find grammatical patterns which hold across languages; it&#39;s been a constant process of people making generalizations that should apply to all languages, only to find out that, all too often, these generalizations fail -- sometimes failing for just a few languages, sometimes whole classes of languages, and sometimes nearly every language in the world except English. Broad statistical trends are evident in what the &quot;average language&quot; is like as far as what its rules can look like, must look like, and cannot look like. But the &quot;average language&quot; is just as unreal a concept as the &quot;average person&quot; -- it runs up against the fact no language (or person) is, in fact, average. The wisdom of past experience leads us to believe that any given language can do whatever it wants, in any order, with appeal to any kind of grammatical categories wants -- case, number, tense, real or metaphoric characteristics of the things that words refer to, arbitrary or predictable classifications of words based on what endings or prefixes they can take, degree or means of certainty about the truth of statements expressed, and so on, ad infinitum.</p>

<p>Mercifully, most localization tasks are a matter of finding ways to translate whole phrases, generally sentences, where the context is relatively set, and where the only variation in content is <i>usually</i> in a number being expressed -- as in the example sentences above. Translating specific, fully-formed sentences is, in practice, fairly foolproof -- which is good, because that&#39;s what&#39;s in the phrasebooks that so many tourists rely on. Now, a given phrase (whether in a phrasebook or in a gettext lexicon) in one language <i>might</i> have a greater or lesser applicability than that phrase&#39;s translation into another language -- for example, strictly speaking, in Arabic, the &quot;your&quot; in &quot;Your query matched...&quot; would take a different form depending on whether the user is male or female; so the Arabic translation &quot;your[feminine] query&quot; is applicable in fewer cases than the corresponding English phrase, which doesn&#39;t distinguish the user&#39;s gender. (In practice, it&#39;s not feasible to have a program know the user&#39;s gender, so the masculine &quot;you&quot; in Arabic is usually used, by default.)</p>

<p>But in general, such surprises are rare when entire sentences are being translated, especially when the functional context is restricted to that of a computer interacting with a user either to convey a fact or to prompt for a piece of information. So, for purposes of localization, translation by phrase (generally by sentence) is both the simplest and the least problematic.</p>

<h2 id="Breaking-gettext"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Breaking-gettext">#</a><a id="Breaking"></a>Breaking gettext</h2>

<ul>

<p>&quot;It Has To Work.&quot;</p>

<p>-- First Networking Truth, RFC 1925</p>

</ul>

<p>Consider that sentences in a tourist phrasebook are of two types: ones like &quot;How do I get to the marketplace?&quot; that don&#39;t have any blanks to fill in, and ones like &quot;How much do these ___ cost?&quot;, where there&#39;s one or more blanks to fill in (and these are usually linked to a list of words that you can put in that blank: &quot;fish&quot;, &quot;potatoes&quot;, &quot;tomatoes&quot;, etc.). The ones with no blanks are no problem, but the fill-in-the-blank ones may not be really straightforward. If it&#39;s a Swahili phrasebook, for example, the authors probably didn&#39;t bother to tell you the complicated ways that the verb &quot;cost&quot; changes its inflectional prefix depending on the noun you&#39;re putting in the blank. The trader in the marketplace will still understand what you&#39;re saying if you say &quot;how much do these potatoes cost?&quot; with the wrong inflectional prefix on &quot;cost&quot;. After all, <i>you</i> can&#39;t speak proper Swahili, <i>you&#39;re</i> just a tourist. But while tourists can be stupid, computers are supposed to be smart; the computer should be able to fill in the blank, and still have the results be grammatical.</p>

<p>In other words, a phrasebook entry takes some values as parameters (the things that you fill in the blank or blanks), and provides a value based on these parameters, where the way you get that final value from the given values can, properly speaking, involve an arbitrarily complex series of operations. (In the case of Chinese, it&#39;d be not at all complex, at least in cases like the examples at the beginning of this article; whereas in the case of Russian it&#39;d be a rather complex series of operations. And in some languages, the complexity could be spread around differently: while the act of putting a number-expression in front of a noun phrase might not be complex by itself, it may change how you have to, for example, inflect a verb elsewhere in the sentence. This is what in syntax is called &quot;long-distance dependencies&quot;.)</p>

<p>This talk of parameters and arbitrary complexity is just another way to say that an entry in a phrasebook is what in a programming language would be called a &quot;function&quot;. Just so you don&#39;t miss it, this is the crux of this article: <i>A phrase is a function; a phrasebook is a bunch of functions.</i></p>

<p>The reason that using gettext runs into walls (as in the above second-person horror story) is that you&#39;re trying to use a string (or worse, a choice among a bunch of strings) to do what you really need a function for -- which is futile. Preforming (s)printf interpolation on the strings which you get back from gettext does allow you to do <i>some</i> common things passably well... sometimes... sort of; but, to paraphrase what some people say about <code>csh</code> script programming, &quot;it fools you into thinking you can use it for real things, but you can&#39;t, and you don&#39;t discover this until you&#39;ve already spent too much time trying, and by then it&#39;s too late.&quot;</p>

<h2 id="Replacing-gettext"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Replacing-gettext">#</a><a id="Replacing"></a>Replacing gettext</h2>

<p>So, what needs to replace gettext is a system that supports lexicons of functions instead of lexicons of strings. An entry in a lexicon from such a system should <i>not</i> look like this:</p>

<pre><code>&quot;J&#39;ai trouv\xE9 %g fichiers dans %g r\xE9pertoires&quot;</code></pre>

<p>[\xE9 is e-acute in Latin-1. Some pod renderers would scream if I used the actual character here. -- SB]</p>

<p>but instead like this, bearing in mind that this is just a first stab:</p>

<pre><code>sub I_found_X1_files_in_X2_directories {
  my( $files, $dirs ) = @_[0,1];
  $files = sprintf(&quot;%g %s&quot;, $files,
    $files == 1 ? &#39;fichier&#39; : &#39;fichiers&#39;);
  $dirs = sprintf(&quot;%g %s&quot;, $dirs,
    $dirs == 1 ? &quot;r\xE9pertoire&quot; : &quot;r\xE9pertoires&quot;);
  return &quot;J&#39;ai trouv\xE9 $files dans $dirs.&quot;;
}</code></pre>

<p>Now, there&#39;s no particularly obvious way to store anything but strings in a gettext lexicon; so it looks like we just have to start over and make something better, from scratch. I call my shot at a gettext-replacement system &quot;Maketext&quot;, or, in CPAN terms, Locale::Maketext.</p>

<p>When designing Maketext, I chose to plan its main features in terms of &quot;buzzword compliance&quot;. And here are the buzzwords:</p>

<h2 id="Buzzwords:-Abstraction-and-Encapsulation"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Buzzwords:-Abstraction-and-Encapsulation">#</a><a id="Buzzwords"></a>Buzzwords: Abstraction and Encapsulation</h2>

<p>The complexity of the language you&#39;re trying to output a phrase in is entirely abstracted inside (and encapsulated within) the Maketext module for that interface. When you call:</p>

<pre><code>print $lang-&gt;maketext(&quot;You have [quant,_1,piece] of new mail.&quot;,
                     scalar(@messages));</code></pre>

<p>you don&#39;t know (and in fact can&#39;t easily find out) whether this will involve lots of figuring, as in Russian (if $lang is a handle to the Russian module), or relatively little, as in Chinese. That kind of abstraction and encapsulation may encourage other pleasant buzzwords like modularization and stratification, depending on what design decisions you make.</p>

<h2 id="Buzzword:-Isomorphism"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Buzzword:-Isomorphism">#</a><a id="Buzzword"></a>Buzzword: Isomorphism</h2>

<p>&quot;Isomorphism&quot; means &quot;having the same structure or form&quot;; in discussions of program design, the word takes on the special, specific meaning that your implementation of a solution to a problem <i>has the same structure</i> as, say, an informal verbal description of the solution, or maybe of the problem itself. Isomorphism is, all things considered, a good thing -- it&#39;s what problem-solving (and solution-implementing) should look like.</p>

<p>What&#39;s wrong the with gettext-using code like this...</p>

<pre><code>printf( $file_count == 1 ?
  ( $directory_count == 1 ?
   &quot;Your query matched %g file in %g directory.&quot; :
   &quot;Your query matched %g file in %g directories.&quot; ) :
  ( $directory_count == 1 ?
   &quot;Your query matched %g files in %g directory.&quot; :
   &quot;Your query matched %g files in %g directories.&quot; ),
 $file_count, $directory_count,
);</code></pre>

<p>is first off that it&#39;s not well abstracted -- these ways of testing for grammatical number (as in the expressions like <code>foo == 1 ? singular_form : plural_form</code>) should be abstracted to each language module, since how you get grammatical number is language-specific.</p>

<p>But second off, it&#39;s not isomorphic -- the &quot;solution&quot; (i.e., the phrasebook entries) for Chinese maps from these four English phrases to the one Chinese phrase that fits for all of them. In other words, the informal solution would be &quot;The way to say what you want in Chinese is with the one phrase &#39;For your question, in Y directories you would find X files&#39;&quot; -- and so the implemented solution should be, isomorphically, just a straightforward way to spit out that one phrase, with numerals properly interpolated. It shouldn&#39;t have to map from the complexity of other languages to the simplicity of this one.</p>

<h2 id="Buzzword:-Inheritance"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Buzzword:-Inheritance">#</a><a id="Buzzword1"></a>Buzzword: Inheritance</h2>

<p>There&#39;s a great deal of reuse possible for sharing of phrases between modules for related dialects, or for sharing of auxiliary functions between related languages. (By &quot;auxiliary functions&quot;, I mean functions that don&#39;t produce phrase-text, but which, say, return an answer to &quot;does this number require a plural noun after it?&quot;. Such auxiliary functions would be used in the internal logic of functions that actually do produce phrase-text.)</p>

<p>In the case of sharing phrases, consider that you have an interface already localized for American English (probably by having been written with that as the native locale, but that&#39;s incidental). Localizing it for UK English should, in practical terms, be just a matter of running it past a British person with the instructions to indicate what few phrases would benefit from a change in spelling or possibly minor rewording. In that case, you should be able to put in the UK English localization module <i>only</i> those phrases that are UK-specific, and for all the rest, <i>inherit</i> from the American English module. (And I expect this same situation would apply with Brazilian and Continental Portugese, possibly with some <i>very</i> closely related languages like Czech and Slovak, and possibly with the slightly different &quot;versions&quot; of written Mandarin Chinese, as I hear exist in Taiwan and mainland China.)</p>

<p>As to sharing of auxiliary functions, consider the problem of Russian numbers from the beginning of this article; obviously, you&#39;d want to write only once the hairy code that, given a numeric value, would return some specification of which case and number a given quantified noun should use. But suppose that you discover, while localizing an interface for, say, Ukrainian (a Slavic language related to Russian, spoken by several million people, many of whom would be relieved to find that your Web site&#39;s or software&#39;s interface is available in their language), that the rules in Ukrainian are the same as in Russian for quantification, and probably for many other grammatical functions. While there may well be no phrases in common between Russian and Ukrainian, you could still choose to have the Ukrainian module inherit from the Russian module, just for the sake of inheriting all the various grammatical methods. Or, probably better organizationally, you could move those functions to a module called <code>_E_Slavic</code> or something, which Russian and Ukrainian could inherit useful functions from, but which would (presumably) provide no lexicon.</p>

<h2 id="Buzzword:-Concision"><a class="permalink" href="./Locale::Maketext::TPJ13.html#Buzzword:-Concision">#</a><a id="Buzzword2"></a>Buzzword: Concision</h2>

<p>Okay, concision isn&#39;t a buzzword. But it should be, so I decree that as a new buzzword, &quot;concision&quot; means that simple common things should be expressible in very few lines (or maybe even just a few characters) of code -- call it a special case of &quot;making simple things easy and hard things possible&quot;, and see also the role it played in the MIDI::Simple language, discussed elsewhere in this issue [TPJ#13].</p>

<p>Consider our first stab at an entry in our &quot;phrasebook of functions&quot;:</p>

<pre><code>sub I_found_X1_files_in_X2_directories {
  my( $files, $dirs ) = @_[0,1];
  $files = sprintf(&quot;%g %s&quot;, $files,
    $files == 1 ? &#39;fichier&#39; : &#39;fichiers&#39;);
  $dirs = sprintf(&quot;%g %s&quot;, $dirs,
    $dirs == 1 ? &quot;r\xE9pertoire&quot; : &quot;r\xE9pertoires&quot;);
  return &quot;J&#39;ai trouv\xE9 $files dans $dirs.&quot;;
}</code></pre>

<p>You may sense that a lexicon (to use a non-committal catch-all term for a collection of things you know how to say, regardless of whether they&#39;re phrases or words) consisting of functions <i>expressed</i> as above would make for rather long-winded and repetitive code -- even if you wisely rewrote this to have quantification (as we call adding a number expression to a noun phrase) be a function called like:</p>

<pre><code>sub I_found_X1_files_in_X2_directories {
  my( $files, $dirs ) = @_[0,1];
  $files = quant($files, &quot;fichier&quot;);
  $dirs =  quant($dirs,  &quot;r\xE9pertoire&quot;);
  return &quot;J&#39;ai trouv\xE9 $files dans $dirs.&quot;;
}</code></pre>

<p>And you may also sense that you do not want to bother your translators with having to write Perl code -- you&#39;d much rather that they spend their <i>very costly time</i> on just translation. And this is to say nothing of the near impossibility of finding a commercial translator who would know even simple Perl.</p>

<p>In a first-hack implementation of Maketext, each language-module&#39;s lexicon looked like this:</p>

<pre><code>%Lexicon = (
  &quot;I found %g files in %g directories&quot;
  =&gt; sub {
     my( $files, $dirs ) = @_[0,1];
     $files = quant($files, &quot;fichier&quot;);
     $dirs =  quant($dirs,  &quot;r\xE9pertoire&quot;);
     return &quot;J&#39;ai trouv\xE9 $files dans $dirs.&quot;;
   },
 ... and so on with other phrase =&gt; sub mappings ...
);</code></pre>

<p>but I immediately went looking for some more concise way to basically denote the same phrase-function -- a way that would also serve to concisely denote <i>most</i> phrase-functions in the lexicon for <i>most</i> languages. After much time and even some actual thought, I decided on this system:</p>

<p>* Where a value in a %Lexicon hash is a contentful string instead of an anonymous sub (or, conceivably, a coderef), it would be interpreted as a sort of shorthand expression of what the sub does. When accessed for the first time in a session, it is parsed, turned into Perl code, and then eval&#39;d into an anonymous sub; then that sub replaces the original string in that lexicon. (That way, the work of parsing and evaling the shorthand form for a given phrase is done no more than once per session.)</p>

<p>* Calls to <code>maketext</code> (as Maketext&#39;s main function is called) happen thru a &quot;language session handle&quot;, notionally very much like an IO handle, in that you open one at the start of the session, and use it for &quot;sending signals&quot; to an object in order to have it return the text you want.</p>

<p>So, this:</p>

<pre><code>$lang-&gt;maketext(&quot;You have [quant,_1,piece] of new mail.&quot;,
               scalar(@messages));</code></pre>

<p>basically means this: look in the lexicon for $lang (which may inherit from any number of other lexicons), and find the function that we happen to associate with the string &quot;You have [quant,_1,piece] of new mail&quot; (which is, and should be, a functioning &quot;shorthand&quot; for this function in the native locale -- English in this case). If you find such a function, call it with $lang as its first parameter (as if it were a method), and then a copy of scalar(@messages) as its second, and then return that value. If that function was found, but was in string shorthand instead of being a fully specified function, parse it and make it into a function before calling it the first time.</p>

<p>* The shorthand uses code in brackets to indicate method calls that should be performed. A full explanation is not in order here, but a few examples will suffice:</p>

<pre><code class="plaintext">&quot;You have [quant,_1,piece] of new mail.&quot;</code></pre>

<p>The above code is shorthand for, and will be interpreted as, this:</p>

<pre><code>sub {
  my $handle = $_[0];
  my(@params) = @_;
  return join &#39;&#39;,
    &quot;You have &quot;,
    $handle-&gt;quant($params[1], &#39;piece&#39;),
    &quot;of new mail.&quot;;
}</code></pre>

<p>where &quot;quant&quot; is the name of a method you&#39;re using to quantify the noun &quot;piece&quot; with the number $params[0].</p>

<p>A string with no brackety calls, like this:</p>

<pre><code class="plaintext">&quot;Your search expression was malformed.&quot;</code></pre>

<p>is somewhat of a degenerate case, and just gets turned into:</p>

<pre><code class="plaintext">sub { return &quot;Your search expression was malformed.&quot; }</code></pre>

<p>However, not everything you can write in Perl code can be written in the above shorthand system -- not by a long shot. For example, consider the Italian translator from the beginning of this article, who wanted the Italian for &quot;I didn&#39;t find any files&quot; as a special case, instead of &quot;I found 0 files&quot;. That couldn&#39;t be specified (at least not easily or simply) in our shorthand system, and it would have to be written out in full, like this:</p>

<pre><code>sub {  # pretend the English strings are in Italian
  my($handle, $files, $dirs) = @_[0,1,2];
  return &quot;I didn&#39;t find any files&quot; unless $files;
  return join &#39;&#39;,
    &quot;I found &quot;,
    $handle-&gt;quant($files, &#39;file&#39;),
    &quot; in &quot;,
    $handle-&gt;quant($dirs,  &#39;directory&#39;),
    &quot;.&quot;;
}</code></pre>

<p>Next to a lexicon full of shorthand code, that sort of sticks out like a sore thumb -- but this <i>is</i> a special case, after all; and at least it&#39;s possible, if not as concise as usual.</p>

<p>As to how you&#39;d implement the Russian example from the beginning of the article, well, There&#39;s More Than One Way To Do It, but it could be something like this (using English words for Russian, just so you know what&#39;s going on):</p>

<pre><code class="plaintext">&quot;I [quant,_1,directory,accusative] scanned.&quot;</code></pre>

<p>This shifts the burden of complexity off to the quant method. That method&#39;s parameters are: the numeric value it&#39;s going to use to quantify something; the Russian word it&#39;s going to quantify; and the parameter &quot;accusative&quot;, which you&#39;re using to mean that this sentence&#39;s syntax wants a noun in the accusative case there, although that quantification method may have to overrule, for grammatical reasons you may recall from the beginning of this article.</p>

<p>Now, the Russian quant method here is responsible not only for implementing the strange logic necessary for figuring out how Russian number-phrases impose case and number on their noun-phrases, but also for inflecting the Russian word for &quot;directory&quot;. How that inflection is to be carried out is no small issue, and among the solutions I&#39;ve seen, some (like variations on a simple lookup in a hash where all possible forms are provided for all necessary words) are straightforward but <i>can</i> become cumbersome when you need to inflect more than a few dozen words; and other solutions (like using algorithms to model the inflections, storing only root forms and irregularities) <i>can</i> involve more overhead than is justifiable for all but the largest lexicons.</p>

<p>Mercifully, this design decision becomes crucial only in the hairiest of inflected languages, of which Russian is by no means the <i>worst</i> case scenario, but is worse than most. Most languages have simpler inflection systems; for example, in English or Swahili, there are generally no more than two possible inflected forms for a given noun (&quot;error/errors&quot;; &quot;kosa/makosa&quot;), and the rules for producing these forms are fairly simple -- or at least, simple rules can be formulated that work for most words, and you can then treat the exceptions as just &quot;irregular&quot;, at least relative to your ad hoc rules. A simpler inflection system (simpler rules, fewer forms) means that design decisions are less crucial to maintaining sanity, whereas the same decisions could incur overhead-versus-scalability problems in languages like Russian. It may <i>also</i> be likely that code (possibly in Perl, as with Lingua::EN::Inflect, for English nouns) has already been written for the language in question, whether simple or complex.</p>

<p>Moreover, a third possibility may even be simpler than anything discussed above: &quot;Just require that all possible (or at least applicable) forms be provided in the call to the given language&#39;s quant method, as in:&quot;</p>

<pre><code class="plaintext">&quot;I found [quant,_1,file,files].&quot;</code></pre>

<p>That way, quant just has to chose which form it needs, without having to look up or generate anything. While possibly not optimal for Russian, this should work well for most other languages, where quantification is not as complicated an operation.</p>

<h2 id="The-Devil-in-the-Details"><a class="permalink" href="./Locale::Maketext::TPJ13.html#The-Devil-in-the-Details">#</a><a id="The1"></a>The Devil in the Details</h2>

<p>There&#39;s plenty more to Maketext than described above -- for example, there&#39;s the details of how language tags (&quot;en-US&quot;, &quot;i-pwn&quot;, &quot;fi&quot;, etc.) or locale IDs (&quot;en_US&quot;) interact with actual module naming (&quot;BogoQuery/Locale/en_us.pm&quot;), and what magic can ensue; there&#39;s the details of how to record (and possibly negotiate) what character encoding Maketext will return text in (UTF8? Latin-1? KOI8?). There&#39;s the interesting fact that Maketext is for localization, but nowhere actually has a &quot;<code>use locale;</code>&quot; anywhere in it. For the curious, there&#39;s the somewhat frightening details of how I actually implement something like data inheritance so that searches across modules&#39; %Lexicon hashes can parallel how Perl implements method inheritance.</p>

<p>And, most importantly, there&#39;s all the practical details of how to actually go about deriving from Maketext so you can use it for your interfaces, and the various tools and conventions for starting out and maintaining individual language modules.</p>

<p>That is all covered in the documentation for Locale::Maketext and the modules that come with it, available in CPAN. After having read this article, which covers the why&#39;s of Maketext, the documentation, which covers the how&#39;s of it, should be quite straightforward.</p>

<h2 id="The-Proof-in-the-Pudding:-Localizing-Web-Sites"><a class="permalink" href="./Locale::Maketext::TPJ13.html#The-Proof-in-the-Pudding:-Localizing-Web-Sites">#</a><a id="The2"></a>The Proof in the Pudding: Localizing Web Sites</h2>

<p>Maketext and gettext have a notable difference: gettext is in C, accessible thru C library calls, whereas Maketext is in Perl, and really can&#39;t work without a Perl interpreter (although I suppose something like it could be written for C). Accidents of history (and not necessarily lucky ones) have made C++ the most common language for the implementation of applications like word processors, Web browsers, and even many in-house applications like custom query systems. Current conditions make it somewhat unlikely that the next one of any of these kinds of applications will be written in Perl, albeit clearly more for reasons of custom and inertia than out of consideration of what is the right tool for the job.</p>

<p>However, other accidents of history have made Perl a well-accepted language for design of server-side programs (generally in CGI form) for Web site interfaces. Localization of static pages in Web sites is trivial, feasible either with simple language-negotiation features in servers like Apache, or with some kind of server-side inclusions of language-appropriate text into layout templates. However, I think that the localization of Perl-based search systems (or other kinds of dynamic content) in Web sites, be they public or access-restricted, is where Maketext will see the greatest use.</p>

<p>I presume that it would be only the exceptional Web site that gets localized for English <i>and</i> Chinese <i>and</i> Italian <i>and</i> Arabic <i>and</i> Russian, to recall the languages from the beginning of this article -- to say nothing of German, Spanish, French, Japanese, Finnish, and Hindi, to name a few languages that benefit from large numbers of programmers or Web viewers or both.</p>

<p>However, the ever-increasing internationalization of the Web (whether measured in terms of amount of content, of numbers of content writers or programmers, or of size of content audiences) makes it increasingly likely that the interface to the average Web-based dynamic content service will be localized for two or maybe three languages. It is my hope that Maketext will make that task as simple as possible, and will remove previous barriers to localization for languages dissimilar to English.</p>

<pre><code class="plaintext">__END__</code></pre>

<p>Sean M. Burke (sburke@cpan.org) has a Master&#39;s in linguistics from Northwestern University; he specializes in language technology. Jordan Lachler (lachler@unm.edu) is a PhD student in the Department of Linguistics at the University of New Mexico; he specializes in morphology and pedagogy of North American native languages.</p>

<h2 id="References"><a class="permalink" href="./Locale::Maketext::TPJ13.html#References">#</a>References</h2>

<p>Alvestrand, Harald Tveit. 1995. <i>RFC 1766: Tags for the Identification of Languages.</i> <code><a href="http://www.ietf.org/rfc/rfc1766.txt">http://www.ietf.org/rfc/rfc1766.txt</a></code> [Now see RFC 3066.]</p>

<p>Callon, Ross, editor. 1996. <i>RFC 1925: The Twelve Networking Truths.</i> <code><a href="http://www.ietf.org/rfc/rfc1925.txt">http://www.ietf.org/rfc/rfc1925.txt</a></code></p>

<p>Drepper, Ulrich, Peter Miller, and François Pinard. 1995-2001. GNU <code>gettext</code>. Available in <code><a href="ftp://prep.ai.mit.edu/pub/gnu/">ftp://prep.ai.mit.edu/pub/gnu/</a></code>, with extensive docs in the distribution tarball. [Since I wrote this article in 1998, I now see that the gettext docs are now trying more to come to terms with plurality. Whether useful conclusions have come from it is another question altogether. -- SMB, May 2001]</p>

<p>Forbes, Nevill. 1964. <i>Russian Grammar.</i> Third Edition, revised by J. C. Dumbreck. Oxford University Press.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
